Open
Conversation
[SKIP CI]
Member
Author
|
大概做完了,实测下来感觉 Bug 不是很多,现在就差个 Yggdrasil 的传统认证组件了 |
0bd4256 to
d26e53f
Compare
4dbbd0e to
d446d78
Compare
Member
Author
|
这堆东西完全没法做任何单元测试,只能等写账号系统的时候一并测掉了 目前手动测试下设备代码流是没什么问题了 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本 PR 旨在提供规范的身份认证组件,以解决 PCL 内部的身份认证实现不规范还一堆 Bug 完全没有可维护性的问题
ToDo List
用例
Important
IdentityModel 不会尝试处理任何错误
因为其设计目标是作为协议传输层将调用方提供的数据转换为标准数据格式(类似 HttpClient)
错误需要调用方自行处理
普通 OAuth
初始化
Tip
PKCE 扩展
如果需要 PKCE 扩展支持,请使用 PkceClient 而不是 SimpleOAuthClient
授权代码流
获取授权 Url
使用授权代码兑换令牌
设备代码流
获取代码对
Important
AuthorizeWithDeviceAsync 仅会发送一次请求(不会轮询)
你可以配合 Polly 做重试,或者自己糊也行,但绝对不能只调用一次
刷新登录
Tip
扩展数据支持
如果某一个协议基于 OAuth 但需要提供更多的请求载荷,你可以设置每个方法的 extData 参数(字典)并提供对应的数据
Warning
不要填写预定义字段
请不要试图填写诸如
client_idgrant_type之类的由 RFC 预先定义的字段,这些字段会被覆盖掉如果实在有需要,请重新开一个类并实现 IOAuthClient 接口
OpenId Connect
Important
IdentityModel 提供的实现为精简版,可能不是标准 OpenID 实现,但应该够用.....吧?
初始化
Tip
设备代码流模式
如果只需要设备代码流登录,请设置 OnlyDeviceAuthorize 为 true,这将跳过 RedirectUri 的检查,从而允许传入空值
Important
因为需要从互联网拉取配置,基于 OpenID 协议(包括 OpenID)实现的客户端均需要在开始使用前调用
.InitializeAsync()Tip
PKCE 支持
OpenID Client 原生支持(并默认启用) PKCE 扩展
如果 PKCE 扩展支持导致登录问题,请设置 EnablePkceSupport 为 false
OpenID Client 的登录过程与 OAuth 相同,请参考 SimpleOAuthClient 的用例
Yggdrasil Connect
Yggdrasil Connect Client 的初始化方式与 OpenID Client 相同,请直接参考 OpenID Client 的初始化方式
Yggdrasli Legacy Login
初始化
登录
刷新
Important
如果需要选择档案,请务必在调用时传递要选择的档案
如果不需要,请移除传递
注销
全域登出
Important
此方法将登出全部账号,无论是不是 PCL CE 登录的